import React from "react";
import { TabBar } from 'antd-mobile';

class TabBarExample extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      selectedTab: 'redTab',
      hidden: false,
      fullScreen: true,
    };
  }
  render() {
    return (
      <div style={this.state.fullScreen ? { position: 'fixed', height: '100%', width: '100%', top: 0 } : { height: 400 }}>
        <TabBar
          unselectedTintColor="#949494"
          tintColor="#ff2d4a"
          barTintColor="white"
          hidden={this.state.hidden}
        >
          <TabBar.Item
            title="首页"
            key="首页"
            icon={
              <i
                className="iconfont icon-home"
                style={{ fontSize: '20px' }}
              ></i>
            }
            selectedIcon={
              <i
                className="iconfont icon-home"
                style={{ color: "#ff2d4a", fontSize: '20px' }}
              ></i>
            }
            selected={this.props.location.pathname === "/"}
            onPress={() => {
              this.props.history.push('/')
            }}
          >
            {this.props.children}
          </TabBar.Item>
          <TabBar.Item
            icon={
              <i
                className='iconfont icon-all'
                style={{ fontSize: '20px' }}
              >
              </i>
            }
            selectedIcon={
              <i
                className='iconfont icon-all'
                style={{ color: "#ff2d4a", fontSize: '20px' }}
              ></i>
            }
            title="分类"
            key="分类"
            selected={this.props.location.pathname === "/category"}
            onPress={() => {
              this.props.history.push('/category')
            }}
          >
            {this.props.children}
          </TabBar.Item>
          <TabBar.Item
            icon={
              <i
                className="iconfont icon-icon-test"
                style={{ fontSize: '20px' }}
              ></i>
            }
            selectedIcon={
              <i
                className="iconfont icon-icon-test"
                style={{ color: "#ff2d4a", fontSize: '20px' }}
              ></i>
            }
            title="购物车"
            key="购物车"
            selected={this.props.location.pathname === "/cart"}
            onPress={() => {
              this.props.history.push('/cart')
            }}
          >
            {this.props.children}
          </TabBar.Item>
          <TabBar.Item
            icon={
              <i
                className="iconfont icon-user"
                style={{ fontSize: '20px' }}
              ></i>
            }
            selectedIcon={
              <i
                className="iconfont icon-user"
                style={{ color: "#ff2d4a", fontSize: '20px' }}
              ></i>
            }
            title="我的"
            key="我的"
            selected={this.props.location.pathname === "/my"}
            onPress={() => {
              this.props.history.push('/my')
            }}
          >
            {this.props.children}
          </TabBar.Item>
        </TabBar>
      </div>
    );
  }
}
export default TabBarExample